home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk69 / jlib20a / cbug < prev    next >
Text File  |  1995-03-19  |  3KB  |  102 lines

  1. 'this file demonstrates the stack overflow bug in the AC/BASIC compiler
  2. ' and a work-around solution to it.
  3. 'the problem occurs when there are more than 249 total arguments in CALLs
  4. ' to machine language routines in any program module
  5. 'the solution (until the bug is fixed, anyway) is to place the ml CALLs in
  6. ' SUB programs and then call the SUB programs.  There is no overflow problem
  7. ' in calling SUB programs
  8. 'this file contains two programs - make two copies and delete everything above
  9. ' the `CUT' line in one, and everything below it in the other.  the top half
  10. ' demonstates the bug and the bottom half demonstrates how you can avoid it.
  11. ' both halves will run in AmigaBASIC, but only the bottom half will compile.
  12.  
  13.   WINDOW 1,,(417,11)-(617,59),31,-1
  14.   DEFINT a-z
  15.  
  16.   rts=&h4e75
  17.  
  18. 'AbSoft docs state that the CALL rts&(1,2...) format must be used in ml calls,
  19. ' but this works! (other than the bug, of course)
  20.  
  21.   rts&=VARPTR(rts)
  22.   rts& 1,2,3,4,5,6,7,8,9,0
  23.   rts& 1,2,3,4,5,6,7,8,9,0
  24.   rts& 1,2,3,4,5,6,7,8,9,0
  25.   rts& 1,2,3,4,5,6,7,8,9,0
  26.   rts& 1,2,3,4,5,6,7,8,9,0
  27.  
  28.   rts& 1,2,3,4,5,6,7,8,9,0
  29.   rts& 1,2,3,4,5,6,7,8,9,0
  30.   rts& 1,2,3,4,5,6,7,8,9,0
  31.   rts& 1,2,3,4,5,6,7,8,9,0
  32.   rts& 1,2,3,4,5,6,7,8,9,0
  33.  
  34.   rts& 1,2,3,4,5,6,7,8,9,0
  35.   rts& 1,2,3,4,5,6,7,8,9,0
  36.   rts& 1,2,3,4,5,6,7,8,9,0
  37.   rts& 1,2,3,4,5,6,7,8,9,0
  38.   rts& 1,2,3,4,5,6,7,8,9,0
  39.  
  40.   rts& 1,2,3,4,5,6,7,8,9,0
  41.   rts& 1,2,3,4,5,6,7,8,9,0
  42.   rts& 1,2,3,4,5,6,7,8,9,0
  43.   rts& 1,2,3,4,5,6,7,8,9,0
  44.   rts& 1,2,3,4,5,6,7,8,9,0
  45.  
  46.   rts& 1,2,3,4,5,6,7,8,9,0
  47.   rts& 1,2,3,4,5,6,7,8,9,0
  48.   rts& 1,2,3,4,5,6,7,8,9,0
  49.   rts& 1,2,3,4,5,6,7,8,9,0
  50.   rts& 1,2,3,4,5,6,7,8,9,0
  51.  
  52.   PRINT "CLICK MOUSE!"
  53.   WHILE MOUSE(0)<>0:WEND:WHILE MOUSE(0)=0:SLEEP:WEND
  54.  
  55. '====================  CUT HERE!  ==========  CUT HERE!  ====================
  56.  
  57.   WINDOW 1,,(417,11)-(617,59),31,-1
  58.   DEFINT a-z
  59.  
  60.   rts=&h4e75
  61.  
  62.   test 1,2,3,4,5,6,7,8,9,0
  63.   test 1,2,3,4,5,6,7,8,9,0
  64.   test 1,2,3,4,5,6,7,8,9,0
  65.   test 1,2,3,4,5,6,7,8,9,0
  66.   test 1,2,3,4,5,6,7,8,9,0
  67.  
  68.   test 1,2,3,4,5,6,7,8,9,0
  69.   test 1,2,3,4,5,6,7,8,9,0
  70.   test 1,2,3,4,5,6,7,8,9,0
  71.   test 1,2,3,4,5,6,7,8,9,0
  72.   test 1,2,3,4,5,6,7,8,9,0
  73.  
  74.   test 1,2,3,4,5,6,7,8,9,0
  75.   test 1,2,3,4,5,6,7,8,9,0
  76.   test 1,2,3,4,5,6,7,8,9,0
  77.   test 1,2,3,4,5,6,7,8,9,0
  78.   test 1,2,3,4,5,6,7,8,9,0
  79.  
  80.   test 1,2,3,4,5,6,7,8,9,0
  81.   test 1,2,3,4,5,6,7,8,9,0
  82.   test 1,2,3,4,5,6,7,8,9,0
  83.   test 1,2,3,4,5,6,7,8,9,0
  84.   test 1,2,3,4,5,6,7,8,9,0
  85.  
  86.   test 1,2,3,4,5,6,7,8,9,0
  87.   test 1,2,3,4,5,6,7,8,9,0
  88.   test 1,2,3,4,5,6,7,8,9,0
  89.   test 1,2,3,4,5,6,7,8,9,0
  90.   test 1,2,3,4,5,6,7,8,9,0
  91.  
  92.   PRINT "CLICK MOUSE!"
  93.   WHILE MOUSE(0)<>0:WEND:WHILE MOUSE(0)=0:SLEEP:WEND
  94.  
  95. SUB test(a,b,c,d,e,f,g,h,i,j) STATIC
  96.   SHARED rts
  97.   rts&=VARPTR(rts)
  98.   rts& a,b,c,d,e,f,g,h,i,j
  99. 'AbSoft docs state that the CALL rts&(1,2...) format must be used in ml calls,
  100. ' but this works! (other than the bug, of course)
  101. END SUB
  102.